import request from '@/utils/request'

// ----- 首页 Dashboard -----
// 获取志愿者数据概览
export function getVolunteerStats() {
  return request({
    url: '/volunteer/stats',
    method: 'get'
  })
}

// 获取志愿者服务时长趋势
export function getServiceHoursTrend(params) {
  return request({
    url: '/volunteer/hours/trend',
    method: 'get',
    params
  })
}

// 获取志愿者项目类型分布
export function getProjectTypeDistribution() {
  return request({
    url: '/volunteer/projects/distribution',
    method: 'get'
  })
}

// 获取志愿者最近活动
export function getRecentActivities() {
  return request({
    url: '/volunteer/activities/recent',
    method: 'get'
  })
}

// 获取志愿者待参与活动
export function getUpcomingActivities() {
  return request({
    url: '/volunteer/activities/upcoming',
    method: 'get'
  })
}

// ----- 个人资料 Profile -----
// 获取志愿者个人资料
export function getVolunteerProfile() {
  return request({
    url: '/volunteer/profile',
    method: 'get'
  })
}

// 更新志愿者个人资料
export function updateVolunteerProfile(data) {
  return request({
    url: '/volunteer/profile',
    method: 'put',
    data
  })
}

// 上传头像
export function uploadAvatar(data) {
  return request({
    url: '/volunteer/avatar',
    method: 'post',
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}

// ----- 服务时长 ServiceHours -----
// 获取志愿者服务时长记录
export function getServiceHours(params) {
  return request({
    url: '/volunteer/hours',
    method: 'get',
    params
  })
}

// 申请服务时长
export function applyServiceHours(data) {
  return request({
    url: '/volunteer/hours',
    method: 'post',
    data
  })
}

// 获取服务时长详情
export function getServiceHourDetail(id) {
  return request({
    url: `/volunteer/hours/${id}`,
    method: 'get'
  })
}

// ----- 项目 Projects -----
// 获取志愿者项目列表
export function getVolunteerProjects(params) {
  return request({
    url: '/volunteer/projects',
    method: 'get',
    params
  })
}

// 获取项目详情
export function getProjectDetail(id) {
  return request({
    url: `/volunteer/projects/${id}`,
    method: 'get'
  })
}

// 参与项目
export function joinProject(id) {
  return request({
    url: `/volunteer/projects/${id}/join`,
    method: 'post'
  })
}

// 退出项目
export function quitProject(id) {
  return request({
    url: `/volunteer/projects/${id}/quit`,
    method: 'post'
  })
}

// ----- 团队 Teams -----
// 获取志愿者团队列表
export function getVolunteerTeams(params) {
  return request({
    url: '/volunteer/teams',
    method: 'get',
    params
  })
}

// 获取团队详情
export function getTeamDetail(id) {
  return request({
    url: `/volunteer/teams/${id}`,
    method: 'get'
  })
}

// 加入团队
export function joinTeam(id) {
  return request({
    url: `/volunteer/teams/${id}/join`,
    method: 'post'
  })
}

// 退出团队
export function quitTeam(id) {
  return request({
    url: `/volunteer/teams/${id}/quit`,
    method: 'post'
  })
}

// ----- 证书 Certificate -----
// 获取志愿者证书
export function getVolunteerCertificate() {
  return request({
    url: '/volunteer/certificate',
    method: 'get'
  })
}

// 下载证书
export function downloadCertificate(id) {
  return request({
    url: `/volunteer/certificate/${id}/download`,
    method: 'get',
    responseType: 'blob'
  })
}

// ----- 评论 Comments -----
// 获取志愿者评论列表
export function getVolunteerComments(params) {
  return request({
    url: '/volunteer/comments',
    method: 'get',
    params
  })
}

// 删除评论
export function deleteComment(id) {
  return request({
    url: `/volunteer/comments/${id}`,
    method: 'delete'
  })
}

// 点赞/取消点赞评论
export function toggleLike(id) {
  return request({
    url: `/volunteer/comments/${id}/like`,
    method: 'post'
  })
}

// ----- 活动 Activities -----
// 获取志愿者活动列表
export function getVolunteerActivities(params) {
  return request({
    url: '/volunteer/activities',
    method: 'get',
    params
  })
}

// 获取活动详情
export function getActivityDetail(id) {
  return request({
    url: `/volunteer/activities/${id}`,
    method: 'get'
  })
}

// 参与活动
export function joinActivity(id) {
  return request({
    url: `/volunteer/activities/${id}/join`,
    method: 'post'
  })
}

// 签到活动
export function checkInActivity(id, data) {
  return request({
    url: `/volunteer/activities/${id}/checkin`,
    method: 'post',
    data
  })
}

// 提交活动反馈
export function submitActivityFeedback(id, data) {
  return request({
    url: `/volunteer/activities/${id}/feedback`,
    method: 'post',
    data
  })
}

// 项目签到/签退
export function signInProject(data) {
  return request({
    url: '/volunteer/projects/sign',
    method: 'post',
    data
  })
}

// 登记服务时长
export function recordServiceHours(data) {
  return request({
    url: '/volunteer/projects/hours',
    method: 'post',
    data
  })
}

// 评价项目
export function rateProject(data) {
  return request({
    url: '/volunteer/projects/rate',
    method: 'post',
    data
  })
}

// 下载项目证书
export function getProjectCertificate(id) {
  return request({
    url: `/volunteer/projects/${id}/certificate`,
    method: 'get',
    responseType: 'blob'
  })
}

// 提交项目问题反馈
export function submitProjectReport(data) {
  return request({
    url: '/volunteer/projects/report',
    method: 'post',
    data
  })
} 